<html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta id="MetaDescription" name="description" content="Multi-threaded recursive directory search.">
    <meta id="MetaKeywords" name="keywords" content="Java, Recursive Directory Search, Get Files, Get Directories, Get Folder Contents">
    <meta id="MetaAuthor" name="author" content="Peter Borissow">
    <meta name="RESOURCE-TYPE" content="DOCUMENT">
    <meta name="DISTRIBUTION" content="GLOBAL">
    <meta id="MetaRobots" name="ROBOTS" content="INDEX, FOLLOW">
    <meta id="MetaGenerator" name="GENERATOR" content="JavaXT">
    <meta id="MetaCopyright" name="COPYRIGHT" content="Copyright © 2006-2013, Peter Borissow">

    <title>JavaXT Directory Search - High performance, multi-threaded, recursive directory search for Java</title>    
    <link rel="stylesheet" type="text/css" href="JavaXT%20Directory%20Search%20-%20High%20performance,%20multi-threaded,%20recursive%20directory%20search%20for%20Java_files/javaxt.css">
    <link rel="icon" type="image/vnd.microsoft.icon" href="http://www.javaxt.com/favicon.ico">
    <script type="text/javascript" src="JavaXT%20Directory%20Search%20-%20High%20performance,%20multi-threaded,%20recursive%20directory%20search%20for%20Java_files/compact.js"></script>

<script>try {  for(var lastpass_iter=0; lastpass_iter < document.forms.length; lastpass_iter++){    var lastpass_f = document.forms[lastpass_iter];    if(typeof(lastpass_f.lpsubmitorig)=="undefined"){      if (typeof(lastpass_f.submit) == "function") {        lastpass_f.lpsubmitorig = lastpass_f.submit;        lastpass_f.submit = function(){          var form = this;          try {            if (document.documentElement && 'createEvent' in document)            {              var forms = document.getElementsByTagName('form');              for (var i=0 ; i<forms.length ; ++i)                if (forms[i]==form)                {                  var element = document.createElement('lpformsubmitdataelement');                  element.setAttribute('formnum',i);                  element.setAttribute('from','submithook');                  document.documentElement.appendChild(element);                  var evt = document.createEvent('Events');                  evt.initEvent('lpformsubmit',true,false);                  element.dispatchEvent(evt);                  break;                }            }          } catch (e) {}          try {            form.lpsubmitorig();          } catch (e) {}        }      }    }  }} catch (e) {}</script></head>
<body background="JavaXT%20Directory%20Search%20-%20High%20performance,%20multi-threaded,%20recursive%20directory%20search%20for%20Java_files/back_gry.gif" marginheight="0" marginwidth="0">

  <table id="OuterTable" style="border-collapse: collapse" align="center" border="0" bordercolor="#FF0000" cellpadding="0" cellspacing="0" height="100%" width="900">
   <tbody><tr>
    <td class="left_border" valign="top"></td>
    <td bgcolor="FFFFFF" height="100%" valign="top">

        <table id="HeaderTable" style="border-collapse: collapse;" align="center" border="0" bordercolor="#111111" cellpadding="0" cellspacing="0" width="100%">
         <tbody><tr>
          <td style="padding-bottom:10px;" bgcolor="CA6E22"><a href="http://www.javaxt.com/"><img alt="JavaXT" src="JavaXT%20Directory%20Search%20-%20High%20performance,%20multi-threaded,%20recursive%20directory%20search%20for%20Java_files/javaxt.jpg" border="0"></a></td>
          <td bgcolor="CA6E22" valign="middle" width="100%">
            <form name="search" method="get" action="/search/"><table align="right"><tbody><tr><td valign="bottom"><img src="JavaXT%20Directory%20Search%20-%20High%20performance,%20multi-threaded,%20recursive%20directory%20search%20for%20Java_files/Search.gif" border="0"></td><td><input name="searchtext" class="search" type="text"></td><td><input name="Action" src="JavaXT%20Directory%20Search%20-%20High%20performance,%20multi-threaded,%20recursive%20directory%20search%20for%20Java_files/go_button.gif" alt="Go" border="0" type="image"></td></tr></tbody></table></form>
          </td>
         </tr>
        </tbody></table>

        <div class="nav-bar">
            <div class="tabs">
                <ul id="tablist">
                    <li class="unremovable"><a href="http://www.javaxt.com/"><b>HOME</b></a></li><li class="unremovable"><a href="http://www.javaxt.com/downloads/"><b>DOWNLOADS</b></a></li><li class="unremovable"><a href="http://www.javaxt.com/documentation/"><b>DOCUMENTATION</b></a></li><li class="unremovable active"><a href="http://www.javaxt.com/wiki/"><b>WIKI</b></a></li><li class="unremovable"><a href="http://www.javaxt.com/about/"><b>ABOUT</b></a></li>
                </ul>
            </div>
        </div>
        <div class="subnav-bar"></div>

        
        <div class="content"><table style="background-color:#FFFFFF;border-collapse:collapse;margin-left:0px;margin-right: 0px;" align="center" border="0" bordercolor="#111111" cellpadding="0" cellspacing="0" height="100%" width="100%"><tbody><tr><td valign="top"><h1>Directory Search</h1>





<p>
This <a href="http://www.javaxt.com/documentation/?jar=javaxt-core.jar&amp;class=Directory&amp;package=javaxt.io">javaxt.io.Directory</a> 
class provides several methods to search for files and directories:
</p><ul>
<li>getFiles() - Returns a list of javaxt.io.File found in a directory</li>
<li>getSubDirectories() - Returns a list of javaxt.io.Directory found in a directory</li>
<li>getChildren() - Returns a list of both javaxt.io.File and javaxt.io.Directory found in a directory</li>
</ul>


<h2>Searching for Files</h2>
There are several different ways to search for files in a directory. Here are a few examples:
<p></p>
<div><div id="highlighter_279054" class="syntaxhighlighter nogutter code-block java"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="java spaces">&nbsp;&nbsp;</code><code class="java plain">javaxt.io.Directory directory = </code><code class="java keyword">new</code> <code class="java plain">javaxt.io.Directory(</code><code class="java string">"/temp"</code><code class="java plain">);</code></div><div class="line number2 index1 alt1"><code class="java spaces">&nbsp;&nbsp;</code><code class="java plain">javaxt.io.File[] files;</code></div><div class="line number3 index2 alt2">&nbsp;</div><div class="line number4 index3 alt1"><code class="java comments">//Return a list of all files found in the current directory</code></div><div class="line number5 index4 alt2"><code class="java spaces">&nbsp;&nbsp;</code><code class="java plain">files = directory.getFiles();</code></div><div class="line number6 index5 alt1">&nbsp;</div><div class="line number7 index6 alt2"><code class="java comments">//Return a list of all files found in the current directory and in any subdirectories</code></div><div class="line number8 index7 alt1"><code class="java spaces">&nbsp;&nbsp;</code><code class="java plain">files = directory.getFiles(</code><code class="java keyword">true</code><code class="java plain">);</code></div><div class="line number9 index8 alt2">&nbsp;</div><div class="line number10 index9 alt1"><code class="java comments">//Return a list of PDF documents found in the current directory and in any subdirectories</code></div><div class="line number11 index10 alt2"><code class="java spaces">&nbsp;&nbsp;</code><code class="java plain">files = directory.getFiles(</code><code class="java string">"*.pdf"</code><code class="java plain">, </code><code class="java keyword">true</code><code class="java plain">);</code></div></div></td></tr></tbody></table></div></div>



<h2>File Filters</h2>
In the last example, we performed a basic basic wildcard search for PDF 
documents (files that end with a .pdf extension).
We did this my specifying a "*.pdf" file filter when we called 
getFiles(). You can also can pass in multiple wildcards using an String 
array.
Here's an example of a resursive directory search using multiple 
wildcards.
<p></p>
<div><div id="highlighter_643442" class="syntaxhighlighter nogutter code-block java"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="java plain">String filter = </code><code class="java keyword">new</code> <code class="java plain">String[]{</code><code class="java string">"*.txt"</code><code class="java plain">, </code><code class="java string">"*.htm"</code><code class="java plain">};</code></div><div class="line number2 index1 alt1"><code class="java plain">javaxt.io.File[] files = directory.getFiles(filter, </code><code class="java keyword">true</code><code class="java plain">);</code></div></div></td></tr></tbody></table></div></div>

<p>Of course, you can also use a standard java.io.FileFilter. Here's a simple example used to find txt files.</p>
<div><div id="highlighter_480229" class="syntaxhighlighter nogutter code-block java"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="java plain">java.io.FileFilter filter = </code><code class="java keyword">new</code> <code class="java plain">java.io.FileFilter() {</code></div><div class="line number2 index1 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">public</code> <code class="java keyword">boolean</code> <code class="java plain">accept(java.io.File file) {</code></div><div class="line number3 index2 alt2">&nbsp;</div><div class="line number4 index3 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">if</code> <code class="java plain">(file.isHidden()) </code><code class="java keyword">return</code> <code class="java keyword">false</code><code class="java plain">;</code></div><div class="line number5 index4 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">else</code><code class="java plain">{</code></div><div class="line number6 index5 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">if</code> <code class="java plain">(file.isDirectory()) </code><code class="java keyword">return</code> <code class="java keyword">true</code><code class="java plain">;</code></div><div class="line number7 index6 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">else</code> <code class="java keyword">return</code> <code class="java plain">(file.getName().endsWith(</code><code class="java string">".txt"</code><code class="java plain">));</code></div><div class="line number8 index7 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number9 index8 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number10 index9 alt1"><code class="java plain">};</code></div><div class="line number11 index10 alt2"><code class="java plain">javaxt.io.File[] files = directory.getFiles(filter, </code><code class="java keyword">true</code><code class="java plain">);</code></div></div></td></tr></tbody></table></div></div>


<h2>Efficient Search</h2>
<p>
In the previous examples, we used the getFiles() method to search for 
files. The getFiles() method returns an array of files. This is OK for 
small directories,
but what if you want to search for tens of thousands of files? Waiting 
for the getFiles() method to return might take several minutes or even 
hours to complete 
and would require large amounts of memory. Instead, you can use the 
getChildren() method and process files and directories 
as soon as they are found.
</p>
<p>
Here's an example used to return all files and directories in a 
directory using the getChildren() method. In this example, we will 
perform a recursive directory search and process files and directories 
as soon as they are found.
</p>
<div><div id="highlighter_399718" class="syntaxhighlighter nogutter code-block java"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="java comments">//Set flags</code></div><div class="line number2 index1 alt1"><code class="java spaces">&nbsp;&nbsp;</code><code class="java keyword">boolean</code> <code class="java plain">recursiveSearch = </code><code class="java keyword">true</code><code class="java plain">;</code></div><div class="line number3 index2 alt2"><code class="java spaces">&nbsp;&nbsp;</code><code class="java plain">Object fileFilter = </code><code class="java keyword">null</code><code class="java plain">;</code></div><div class="line number4 index3 alt1"><code class="java spaces">&nbsp;&nbsp;</code><code class="java keyword">boolean</code> <code class="java plain">wait = </code><code class="java keyword">false</code><code class="java plain">;</code></div><div class="line number5 index4 alt2">&nbsp;</div><div class="line number6 index5 alt1"><code class="java comments">//Initiate search</code></div><div class="line number7 index6 alt2"><code class="java spaces">&nbsp;&nbsp;</code><code class="java plain">java.util.List results = directory.getChildren(recursiveSearch, fileFilter, wait);</code></div><div class="line number8 index7 alt1"><code class="java spaces">&nbsp;&nbsp;</code><code class="java keyword">while</code> <code class="java plain">(</code><code class="java keyword">true</code><code class="java plain">){</code></div><div class="line number9 index8 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">Object item;</code></div><div class="line number10 index9 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">synchronized</code> <code class="java plain">(results) {</code></div><div class="line number11 index10 alt2">&nbsp;</div><div class="line number12 index11 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java comments">//Wait for files/directories to be added to the list</code></div><div class="line number13 index12 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">while</code> <code class="java plain">(results.isEmpty()) {</code></div><div class="line number14 index13 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">try</code> <code class="java plain">{</code></div><div class="line number15 index14 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">results.wait();</code></div><div class="line number16 index15 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number17 index16 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">catch</code> <code class="java plain">(InterruptedException e) {</code></div><div class="line number18 index17 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">break</code><code class="java plain">;</code></div><div class="line number19 index18 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number20 index19 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number21 index20 alt2">&nbsp;</div><div class="line number22 index21 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java comments">//Grab the next available file/directory from the list</code></div><div class="line number23 index22 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">item = results.remove(</code><code class="java value">0</code><code class="java plain">);</code></div><div class="line number24 index23 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">results.notifyAll();</code></div><div class="line number25 index24 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number26 index25 alt1">&nbsp;</div><div class="line number27 index26 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java comments">//Do something with the file/directory</code></div><div class="line number28 index27 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">if</code> <code class="java plain">(item!=</code><code class="java keyword">null</code><code class="java plain">){</code></div><div class="line number29 index28 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">if</code> <code class="java plain">(item </code><code class="java keyword">instanceof</code> <code class="java plain">javaxt.io.File){</code></div><div class="line number30 index29 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">javaxt.io.File file = (javaxt.io.File) item;</code></div><div class="line number31 index30 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">System.out.println(file);</code></div><div class="line number32 index31 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number33 index32 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">else</code><code class="java plain">{</code></div><div class="line number34 index33 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">javaxt.io.Directory dir = (javaxt.io.Directory) item;</code></div><div class="line number35 index34 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">System.out.println(dir);</code></div><div class="line number36 index35 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number37 index36 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number38 index37 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">else</code><code class="java plain">{ </code><code class="java comments">//Item is null. This is our queue that the search is done!</code></div><div class="line number39 index38 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">break</code><code class="java plain">; </code></div><div class="line number40 index39 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number41 index40 alt2"><code class="java spaces">&nbsp;&nbsp;</code><code class="java plain">}</code></div></div></td></tr></tbody></table></div></div>

<h2>Recursive Search</h2>
Recursive directory searches highlighted in the examples above are 
extremely fast. This is thanks, in large part, to the multi-threaded 
design of 
the javaxt.io.Directory class. Additional efficiencies are gained on 
Windows file systems by leveraging native Windows API (via the 
javaxt-core JNI).
On Windows file systems, the directory search is approximately 2x faster
 than the java.io.File listFiles() method on local file systems and over
 10x 
faster searching network drives.


<h2>Additional Options for Windows</h2>
The javaxt.io.Directory class offers several additional capabilities 
specific for JVMs running on Windows. Among these is the ability to list
 all the
shared drives found on a server. Example:
<div><div id="highlighter_698818" class="syntaxhighlighter nogutter code-block java"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="java plain">String serverName = </code><code class="java string">"\\\\Orion"</code><code class="java plain">; </code><code class="java comments">//&lt;--Can also be an IP address like "\\192.168.0.1"</code></div><div class="line number2 index1 alt1"><code class="java keyword">for</code> <code class="java plain">(javaxt.io.Directory share : </code><code class="java keyword">new</code> <code class="java plain">javaxt.io.Directory(serverName).getSubDirectories()){</code></div><div class="line number3 index2 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">System.out.println(share);</code></div><div class="line number4 index3 alt1"><code class="java plain">}</code></div></div></td></tr></tbody></table></div></div>

Another Windows-specific feature is the ability to list all the 
root/logical drives on the host machine, including disconnected
network drives. This is something not available in the standard Java 
release (java.io.File.listRoots() does not return disconnected
network drives on Windows).
<div><div id="highlighter_365211" class="syntaxhighlighter nogutter code-block java"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="java keyword">for</code> <code class="java plain">(javaxt.io.Directory drive : javaxt.io.Directory.getRootDirectories()){</code></div><div class="line number2 index1 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">System.out.println(drive);</code></div><div class="line number3 index2 alt2"><code class="java plain">}</code></div></div></td></tr></tbody></table></div></div></td></tr></tbody></table></div>


    </td>
    <td class="right_border" valign="top"></td>
   </tr>


   <tr>
    <td class="ll_border"></td>
    <td>
      <table style="border-collapse: collapse" border="0" cellpadding="0" cellspacing="0" width="100%">
       <tbody><tr>
          <td class="ll2_border"></td>
          <td class="bottom_border"></td>
          <td class="lr2_border"></td>
       </tr>
      </tbody></table>

    </td>
    <td class="lr_border"></td>
   </tr>


   <tr>
    <td colspan="3">
      <div class="copyright" align="center">Copyright © 2006-2013, Peter Borissow</div>
    </td>
   </tr>

  </tbody></table>



    <script type="text/javascript">

      //Hack to setup default brush
        var nodes = document.getElementsByTagName("pre");
        for (var i=0; i<nodes.length; i++){
            var pre = nodes[i];
            if (pre.className==""){ pre.className = "brush: java;"; }
        }

        SyntaxHighlighter.defaults['class-name'] = 'code-block';
        SyntaxHighlighter.defaults['toolbar'] = false;
        SyntaxHighlighter.defaults['gutter'] = false;
        SyntaxHighlighter.all();

    </script>


        </body></html>